<template>
  <div class="app-container">
    <div class="item2">
      <div class="header">
        <div class="title1">
          <i class="el-icon-data-analysis"></i><span>拼箱体积查询</span>
        </div>
        <div class="backB">
          <img src="@/assets/images/back.png" alt="" @click="goBack" />
        </div>
      </div>
      <div class="formCenter">
        <el-form
          :model="queryParams"
          size="large"
          :inline="true"
          ref="queryForm"
          label-width="120px"
        >
        <el-form-item label="运单号:" prop="containerNo">
            <el-input
              v-model="queryParams.containerNo"
              placeholder="请输入运单号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="订单号:" prop="billNo">
            <el-input
              v-model="queryParams.billNo"
              placeholder="请输入订单号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="物流类型:" prop="wlType">
            <el-select
              v-model="queryParams.wlType"
              placeholder="请选择物流类型"
              clearable
            >
              <el-option
                v-for="dict in dict.type.wl_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="日期:" prop="addTime">
            <el-date-picker
              v-model="addTime"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="medium"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-refresh"
              size="medium"
              @click="resetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
        <div class="exportstyle">
          <el-button
            type="primary"
            plain
            icon="el-icon-download"
            size="medium"
            class="exportBtn"
            @click="handleExport"
            >导出</el-button
          >
        </div>
      </div>
      <el-table
        :data="tableData"
        border
        height="680"
        v-loading="loading"
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        :header-cell-style="{ background: '#1890ff', color: '#ffffff' }"
      >
        <!-- <el-table-column align="center" prop="wlType" label="物流类型">
        </el-table-column> -->
        <el-table-column align="center" prop="containerNo" label="运单号">
        </el-table-column>
        <el-table-column align="center" prop="billNo" label="订单号">
        </el-table-column>
        <el-table-column align="center" prop="weight" label="重量(千克)">
        </el-table-column>
        <el-table-column align="center" prop="length" label="长(厘米)">
        </el-table-column>
        <el-table-column align="center" prop="width" label="宽(厘米)">
        </el-table-column>
        <el-table-column align="center" prop="hight" label="高(厘米)">
        </el-table-column>
        <el-table-column align="center" prop="volume" label="体积(立方分米)">
        </el-table-column>
        <el-table-column align="center" prop="uploadtime" label="日期">
        </el-table-column>
      </el-table>
      <div>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="handleQuery"
        />
      </div>
    </div>
  </div>
</template>

<script>
import { sxhcCarlist } from "@/api/subSystem/continer";
export default {
  dicts: ["wl_type"],
  data() {
    return {
      // 密码验证
      centerDialogVisible: false,
      passForm: {
        pass: null,
        account: null,
      },
      passrules: {
        // pass: [{ validator: passwordError, trigger: "blur" }],
        pass: [{ required: true, message: "请输入密码", trigger: "blur" }],
        account: [{ required: true, message: "请输入账号", trigger: "blur" }],
      },
      // 总条数
      total: 0,
      addTime: [
        new Date().toISOString().split("T")[0],
        new Date().toISOString().split("T")[0],
      ],
      //   addTime: [],
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        billNo:"",
        containerNo: "",
        wlType:"",
      },
      tableData: [],
      loading: false,
    };
  },
  mounted() {
    this.handleQuery();
    // this.volumeList();
  },
  methods: {
    resetQuery() {
      this.resetForm("queryForm");
      this.addTime = [];
    //   this.queryParams.params["beginTime"] = this.addTime[0];
    //   this.queryParams.params["endTime"] = this.addTime[1];
    //   this.volumeList();
    },
    goBack() {
      this.$router.push("/subSystem1");
    },
    // volumeList() {
    //   sxhcCarlist(this.queryParams).then((res) => {
    //     this.tableData = res.rows;
    //     this.total = res.total;
    //     this.loading = false;
    //   });
    // },
    handleQuery() {
      this.$refs.queryForm.validate((valid) => {
        if (valid) {
          this.loading = true;
          this.queryParams.params = {};
          if (null != this.addTime && "" != this.addTime) {
            this.queryParams.params["beginTime"] = this.addTime[0];
            this.queryParams.params["endTime"] = this.addTime[1];
          }
            sxhcCarlist(this.queryParams).then((res) => {
              this.tableData = res.rows;
              this.total = res.total;
              this.loading = false;
            });
        }
      });
    },
    handleExport() {
      this.download(
        "system/sxhcCar/export",
        {
          ...this.queryParams,
        },
        `post_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss" scoped>
.app-container {
  .el-icon-data-analysis::before {
    color: #00d9ff;
    margin-right: 8px;
  }
  .title1 {
    font-size: 16px;
    // margin-bottom: 15px;
    color: #808080;
    width: 200px;
    padding: 5px;
    border-bottom: 1px dotted #8ddfff;
  }
  .header {
    margin-top: -10px;
    margin-bottom: 20px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .el-date-editor.el-input,
    .el-date-editor.el-input__inner {
      width: 220px;
      margin-right: 20px;
    }

    .backB {
      cursor: pointer;

      img {
        width: 20%;
      }
    }
  }
  .formCenter {
    width: 100%;
    // height: 62px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .footer {
    margin-top: 20px;
    width: 100%;
    min-height: 200px;
  }
  .el-select {
    width: 240px;
  }
  ::v-deep .el-form {
    margin-left: 1%;
  }
  .exportstyle {
    height: 62px;
    margin-right: 5%;
  }
}
</style>